<?php

namespace app\store\model;

use think\Model;

class Order extends Model
{
    protected $autoWriteTimestamp = false;

    protected $schema = [
        'id' => 'int',
        'user_id' => 'int',
        'store_id' => 'int',
        'order_type' =>'int',
        'order_no' => 'string',
        'payment_type' => 'int',
        'discount_amount' => 'float',
        'real_amount' => 'float',
        'redeem_integral' => 'int',
        'remark' => 'string',
        'comment_status' => 'int',
        'status' => 'int',
        'is_after_sale' => 'int',
        'after_sale_status' => 'int',
        'create_time' => 'int',
        'payment_time' => 'string',
        'ship_status' => 'int',
        'ship_time' => 'int',
        'finish_time' => 'int',
        'cancel_time' => 'int',
    ];

    public function items()
    {
        return $this->hasMany(OrderItem::class);
    }

    public function address()
    {
        return $this->hasOne(OrderAddress::class);
    }

    public function trade()
    {
        return $this->hasMany(OrderTrade::class);
    }


    public function user()
    {
        return $this->belongsTo(User::class);
    }

}